﻿using System; 
using System.Reflection;
using System.ComponentModel;

namespace System.Extensions
{
    public class ConversionType
    {
        public static Type InitConversionType(PropertyInfo property)
        {
            Type conversionType = property.PropertyType;
            if (conversionType.IsGenericType &&
                conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
            {
                NullableConverter nullableConverter = new NullableConverter(conversionType);
                conversionType = nullableConverter.UnderlyingType;
            }
            return conversionType;
        }
    }
}
